#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

int n;
vector<vector<char>> sea;
vector<vector<bool>> check;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int total=0;
int yan=0;

void bfs(int x,int y){
    queue<pair<int,int>> q;
    q.push({x,y});
    check[x][y]=true;
    bool willyan=true;
    while(!q.empty()){
        auto [cx,cy]=q.front();
        q.pop();
        bool isedge=false;
        for(int i=0;i<4;i++){
            int xx=cx+dx[i];
            int yy=cy+dy[i];
            if((xx>=1&&xx<=n)&&(yy>=1&&yy<=n)){
                if(sea[xx][yy]=='.'&&!check[xx][yy])isedge=true;
                if(sea[xx][yy]=='#'&&!check[xx][yy]){
                    check[xx][yy]=true;
                    q.push({xx,yy});
                }
            }
        }
        if(!isedge){
            willyan=false;
        }
    }
    if(willyan){
        yan++;
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>n;
    sea.resize(n+1,vector<char>(n+1,'.'));
    check.resize(n+1,vector<bool>(n+1,0));

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>sea[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(sea[i][j]=='#'&&!check[i][j]){
                total++;
                bfs(i,j);
            }
        }
    }
    cout<<yan<<endl;

    return 0;
}